<template>
    <slot></slot>
</template>
<script setup>
import { defineExpose, defineProps, ref, toRef } from 'vue';
const props = defineProps({
    src: String

    //音频文件的URL
});
const audioUrl = toRef(props, 'src'); // 音频文件的URL
const audioPlayer = ref(new Audio(audioUrl.value));

function playAudio() {
     if (audioPlayer.value.paused) {

        audioPlayer.value.play();

    } else {
        audioPlayer.value.pause();

    }
}
//暂停
function pause() {
    if (audioPlayer.value.play) {
         audioPlayer.value.pause();

    }

}
 
defineExpose({
    playAudio, pause
})
</script>
<style scoped></style>